const babelCore = require('@babel/core')

const code = `
    var x = { a: 5, a: 6 };
    var y = {
      get a() {},
      set a(x) {},
      a: 3,
    };
`
const result = babelCore.transformSync(code,{
    plugins: ["@babel/plugin-transform-duplicate-keys"]
})

console.log(result.code);